<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>按钮悬停效果</title>
  <style>
    body {
      height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    a {
      text-decoration: none;
      color: #fff;
    }

    /* 自定义效果 */
    .btn {
      position: relative;
      border: none;
      text-align: center;
      cursor: pointer;
      outline: none;
      color: #fff;
      font-weight: 700;
      font-size: 15px;
      background-color: #222;
      padding: 17px 60px;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
      /* 伪元素遮罩超出按钮区域的部分隐藏 */
      overflow: hidden;
    }

    /* 使文本脱离文档流并不被遮挡 */
    .btn span {
      position: relative;
      z-index: 1;
    }

    .btn::after {
      content: "";
      position: absolute;
      left: 0;
      top: 0;
      height: 490%;
      width: 140%;
      background: #78c7d2;
      transition: all 0.5s ease-in-out;
      -webkit-transition: all 0.5s ease-in-out;
      transform: translateX(-98%) translateY(-25%) rotate(45deg);
      -webkit-transform: translateX(-98%) translateY(-25%) rotate(45deg);
    }

    .btn:hover::after {
      transform: translateX(-9%) translateY(-25%) rotate(45deg);
    }
  </style>
</head>

<body>
  <button class="btn"><a href="https://codepen.io/himalayasingh/pen/EdVzNL"><span>参考来源</span></a></button>
</body>

</html>